﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Toeplitz
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                int[][] matrix = new int[][] {
                    new int[]{ 1, 2, 3, 4 },
                    new int[]{ 5,1,2,3},
                    new int[]{9,5,1,2}};
                StringBuilder s = new StringBuilder();
                foreach(var arr in matrix)
                    s.Append(string.Join(" ", arr) + "\n");
                s.Append(IsToeplitz(matrix));
                Console.WriteLine(s);
            }
            finally
            {
                Console.ReadKey();
            }
        }
        static bool IsToeplitz(int[][] matrix)
        {
            if (matrix.Length == 0 || matrix[0].Length == 0) throw new ArgumentException();
            int rLen = matrix.Length, cLen = matrix[0].Length;
            int l = 1;
            for (int r = 1; r < rLen; r++)
            {
                for (l = 1; l < cLen; l++)
                {
                    if (matrix[r][l] != matrix[r - 1][l - 1]) return false;
                }
            }
            return true;
        }
    }
}
